package org.lennon.demo.ddd.ticket.message.impl;

import org.lennon.demo.ddd.message.MessageSender;
import org.lennon.demo.ddd.ticket.aggregate.Ticket;
import org.lennon.demo.ddd.ticket.message.TicketMessageService;
import org.lennon.demo.ddd.ticket.message.constants.MessageTopic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TicketMessageServiceImpl implements TicketMessageService {

    @Autowired
    private MessageSender messageSender;

    @Override
    public boolean sendTicketAddMessage(Ticket ticket) {
        messageSender.sendMessage(
                MessageTopic.TICKET_ADD.getTopic(),
                MessageTopic.TICKET_ADD.getTag(),
                ticket.toString().getBytes()
        );
        return true;
    }
}
